#include "TestSession.h"

EXPORT_C TInt RTestSession::SumL(TInt aA, TInt aB)
    {
    Api::SumArgsType args(aA, aB);
    Api::SumRetType ret;
    CleanupClosePushL(args);
    CleanupClosePushL(ret);
    
    iApi.iSum.CallL(*this, ret, args);
    TInt retVal = ret.Data();
    CleanupStack::PopAndDestroy(2, &args);
    return retVal;
    }

EXPORT_C HBufC * RTestSession::ConcatenateL(TDesC const & aFirst, TDesC const & aSecond)
    {
    Api::ConcatenateArgsType args(aFirst, aSecond);
    Api::ConcatenateRetType ret;
    CleanupClosePushL(args);
    CleanupClosePushL(ret);
    
    iApi.iConcatenate.CallL(*this, ret, args);
    HBufC * retBuf = ret.Data().AdoptL();
    CleanupStack::PopAndDestroy(2, &args);
    return retBuf;
    }

EXPORT_C void RTestSession::ConcatenateL(TDesC const & aFirst, TDesC const & aSecond, TRequestStatus & aStatus)
    {
    Api::ConcatenateArgsType args(aFirst, aSecond);
    //CleanupClosePushL(args);
    
    iApi.iConcatenateAsync.CallL(*this, args, aStatus);
    //CleanupStack::PopAndDestroy(&args);
    }

EXPORT_C HBufC * RTestSession::ConcatenateResult()
    {
    Api::ConcatenateRetType ret;
    CleanupClosePushL(ret);
    
    iApi.iConcatenateAsync.GetResult(*this, ret);
    HBufC * retBuf = ret.Data().AdoptL();
    CleanupStack::PopAndDestroy(&ret);
    return retBuf;
    }
    
